package cn.signalpha.modules.shop.controller.api;

import cn.signalpha.common.constant.AppConstant;
import cn.signalpha.core.boot.ctrl.BaseController;
import cn.signalpha.core.mp.support.Condition;
import cn.signalpha.core.mp.support.Query;
import cn.signalpha.core.tool.api.R;
import cn.signalpha.core.tool.utils.Func;
import cn.signalpha.modules.shop.service.FootprintService;
import cn.signalpha.modules.shop.vo.FootprintVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;


/**
 * 购物车
 *
 * @author suguangjun
 */
@RestController
@AllArgsConstructor
@RequestMapping(AppConstant.APPLICATION_SHOP_NAME + "/wap/footprint")
@Api(value = "用户足迹", tags = "用户足迹")
public class ApiFootprintController extends BaseController {

    private final FootprintService footprintService;

    @GetMapping("/page")
    @ApiOperation(value = "分页", notes = "")
    public R<IPage<FootprintVO>> page(@ApiIgnore @RequestParam Map<String, Object> params, Query query){
        params.put("userId", getUser().getUserId().toString());
        return R.data(footprintService.selectFootprintPage(Condition.getPage(query), params));
    }

    @PostMapping("/remove")
    @ApiOperation(value = "删除", notes = "传入ids")
    public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return R.status(footprintService.removeByIds(Func.toLongList(ids)));
    }

}
